package com.emagic.manage.data.repository;

import android.content.Context;

import com.emagic.manage.data.datasource.DataSourceFactory;
import com.emagic.manage.data.db.entry.DaoMaster;
import com.emagic.manage.data.entities.response.Empty;
import com.emagic.manage.data.entities.response.OutOffResponse;
import com.emagic.manage.data.entities.response.RoomsResponse;
import com.emagic.manage.data.entities.response.UserResponse;
import com.emagic.manage.data.oss.OSSFileHelper;

import java.util.Map;

import javax.inject.Inject;
import javax.inject.Singleton;

import rx.Observable;
import timber.log.Timber;

/**
 * {@link Repository} 获取数据
 *
 * @author baoy
 * @version 1.0
 *          Create by 16/1/8 下午1:58
 */
@Singleton
public class DataRepository implements Repository {

    private final DataSourceFactory mDataSourceFactory;
    private final DaoMaster mDaoMaster;
    private final Context mContext;
    private final OSSFileHelper ossFileHelper;

    @Inject
    public DataRepository(Context context, DataSourceFactory dataSourceFactory,
                          DaoMaster daoMaster, OSSFileHelper ossFileHelper) {
        this.mDataSourceFactory = dataSourceFactory;
        this.mContext = context;
        this.mDaoMaster = daoMaster;
        this.ossFileHelper = ossFileHelper;

        Timber.v("new DataRepository");
    }

    @Override
    public Observable<UserResponse> loginapi(String phone, String pwd, String cidentifier,
                                             String alias) {
        return mDataSourceFactory.createRestDataSource().loginapi(phone, pwd, cidentifier, alias);
    }

    @Override
    public Observable<RoomsResponse> getallroom(String userid) {
        return mDataSourceFactory.createRestDataSource().getallroom(userid);
    }

    @Override
    public Observable<OutOffResponse> logOut(String userid, String sessionid) {
        return mDataSourceFactory.createRestDataSource().logOut(userid, sessionid);
    }

    @Override
    public Observable<OutOffResponse> getroom(String serial) {
        return mDataSourceFactory.createRestDataSource().getroom(serial);
    }

    @Override
    public Observable<Empty> sendgift(String serial, String sendid, String sendname, Map studios) {
        return mDataSourceFactory.createRestDataSource().sendgift(serial, sendid, sendname, studios);
    }
}
